package com.woniu.product.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

@Component
public class ServiceTypeRabbitDirectConfig {

    // 创建交换机
    @Bean
    public Exchange serviceTypeExchange(){
        return new DirectExchange("service_type_exchange",true,false,null);
    }
    // 创建队列
    @Bean
    public Queue queueServiceType(){
        return new Queue("service_type_queue",true,false,false,null);
    }
    // 绑定关系
    @Bean
    public Binding bindingServiceType(@Qualifier("queueServiceType") Queue queue , Exchange serviceTypeExchange){
        return BindingBuilder.bind(queue).to(serviceTypeExchange).with("add_service_type").noargs();
    }

}
